#include <bits/stdc++.h>

#include <type_traits>

inline namespace templates {
	long long power(long long x, long long y, unsigned mod) {
		long long r = 1;
		for (; y; y >>= 1, x = x * x % mod) {
			if (y & 1)
				r = r * x % mod;
		}
		return r % mod;
	}
	template <typename T, typename U>
	std::common_type_t<T, U> floor_div(T x, U y) {
		if (y < 0)
			x = -x, y = -y;
		return x >= 0 ? x / y : -((-x + y - 1) / y);
	}
	template <typename T, typename U>
	std::common_type_t<T, U> ceil_div(T x, U y) {
		if (y < 0)
			x = -x, y = -y;
		return x >= 0 ? (x + y - 1) / y : -((-x) / y);
	}
	template <typename T, typename U>
	std::common_type_t<T, U> strict_mod(T x, U y) {
		return x - y * floor_div(x, y);
	}
	template <typename T, typename U, typename W = std::common_type_t<T, U>>
	void exgcd(T a, U b, W &x, W &y) {
		if (!b) {
			x = 1, y = 0;
			return;
		}
		exgcd(b, strict_mod(a, b), y, x);
		y -= floor_div(a, b) * x;
	}
	template <typename T, typename U, typename W = std::common_type_t<T, U>>
	W inverse(T a, U m) {
		W x, y;
		exgcd(a, m, x, y);
		return (x % m + m) % m;
	}
} // namespace templates
using namespace std;
#define For(Ti,Ta,Tb) for(auto Ti=(Ta);Ti<=(Tb);++Ti)
#define Dec(Ti,Ta,Tb) for(auto Ti=(Ta);Ti>=(Tb);--Ti)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define range(Tx) begin(Tx),end(Tx)
using ll=long long;
struct FastMod{
	using ull=unsigned long long;
	using L=__int128;
	ull b,m;
	FastMod(ull b):b(b),m(ull((L(1)<<64)/b)){}
	ull reduce(ull a) const{
		ull q=(ull)((L(m)*a)>>64),r=a-q*b;
		return r>=b?r-b:r;
	}
}F(2);
ll operator%(ll x,const FastMod& F){
	return F.reduce(x);
}
const int N=5e5+5;
int n,q,p;
ll a[N];
struct Info{
	ll a,m;
};
Info solve(ll a,ll b,ll m){
	ll g=__gcd(a,m),x,y;
	if(b%g) return {-1,0};
	m/=g;
	exgcd(a/g,m,x,y);
	return {(x%m+m)%m*(b/g)%m,m};
}
pair<bool,Info> merge(const Info& lhs,const Info& rhs){
	auto [a1,m1]=lhs;
	auto [a2,m2]=rhs;
	auto [x,_]=solve(m1,((a2-a1)%m2+m2)%m2,m2);
	if(!~x) return {0,{}};
	x*=m1;
	ll m=m1/__gcd(m1,m2)*m2;
	return {1,{(a1+x)%m,m}};
}
namespace bf{
	int solve1(ll x){
		auto work=[&](int l,int r){
			ll val=-1,ans=0;
			for(;1<=l&&r<=n;++ans,--l,++r){
				ll v1=(x*a[l]-a[r]+p)%F,v2=(x*a[r]-a[l]+p)%F;
				if(v1!=v2||(~val&&v1!=val)) break;
				val=v1;
			}
			return ans;
		};
		int ans=0;
		For(i,1,n){
			ans+=work(i,i);
			if(i<n) ans+=work(i,i+1);
		}
		return ans;
	}
	ll solve2(ll x){
		auto work=[&](int l,int r){
			Info eq{0,1};
			ll ans=0;
			auto add_eq=[&](ll a,ll b){
				if(!a) return !b;
				Info cur=::solve(a,b,p);
				if(!~cur.a) return false;
				auto [ok,eq_]=merge(eq,cur);
				if(!ok) return false;
				eq=eq_;
				return true;
			};
			for(;1<=l&&r<=n;--l,++r){
				if(!add_eq(a[l],(a[r]-x+p)%F)||!add_eq(a[r],(a[l]-x+p)%F)){
					break;
				}
				ans+=p/eq.m;
			}
			return ans;
		};
		ll ans=0;
		For(i,1,n){
			ans+=work(i,i);
			if(i<n) ans+=work(i,i+1);
		}
		return ans;
	}
	void solve(){
		For($,1,q){
			int op,x;
			cin>>op>>x;
			if(op==1){
				cout<<solve1(x)<<'\n';
			}else{
				cout<<solve2(x)<<'\n';
			}
		}
	}
}
int main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	assert(freopen("string.in","r",stdin));
	assert(freopen("string.out","w",stdout));
	cin>>n>>q>>p;
	F=FastMod(p);
	For(i,1,n){
		cin>>a[i];
	}
	bf::solve();
	return 0;
}